@extends("layout.admin")

@section("title")
    考试批次管理
@endsection

@section("content")
    {{--列表--}}
    <div class="layui-card-body ">
        <form id="search-form">
            <input type="hidden" name="basic_id" value="{{request('basic_id')}}">
        </form>
        <div><h3>考场名称：{{$basic}}</h3></div>
        <script type="text/html" id="toolbar">
            <div class="layui-btn-container">
                @if(_can('admin.basic.create'))
                    <a class="layui-btn layui-btn-sm" onclick="admin.openLayerForm('{{route("admin.basic.examcreate",['basic_id'=>request('basic_id')])}}', '添加考试批次', 'POST', '600px', '550px')"><i class="layui-icon"></i>添加考试批次</a>
                @endif
                    <a class="layui-btn layui-btn-sm" href="{{route('admin.basic.index')}}"><i class="layui-icon"></i>考场管理</a>
            </div>
        </script>
        <table lay-filter="table-hide" style="display: none"  id="demo" lay-data="{height:'full-310', cellMinWidth: 80,toolbar: '#toolbar',defaultToolbar:['filter'],limit:{{$data['per_page']}}}">
            <thead>
            <tr>
                <th lay-data="{width:80,type:'checkbox',field:'id'}"></th>
                <th lay-data="{field:'name'}">考试批次名称</th>
                <th lay-data="{field:'exam_start_at'}">考试时间</th>
                <th lay-data="{field:'address',hide:true}">考试地址</th>
                <th lay-data="{field:'created_at',hide:true}">创建时间</th>
                <th lay-data="{field:'updated_at',hide:true}">更新时间</th>
                <th lay-data="{field:'op',fixed: 'right', width:220, align:'center',toolbar: '#buttons'}">操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach ($data['data'] as $vo)
                <tr>
                    <td>{{$vo['id']}}</td>
                    <td>{{ $vo['name'] }}</td>
                    <td>{{ $vo['exam_start_at'] }} ~ {{ $vo['exam_end_at'] }}</td>
                    <td>{{ $vo['address'] }}</td>
                    <td>{{ $vo['created_at'] }}</td>
                    <td>{{ $vo['updated_at'] }}</td>
                    <td>
                        <script type="text/html" id="buttons">
                            <a class="layui-btn layui-btn-xs" lay-event="more">更多 <i
                                    class="layui-icon layui-icon-down"></i></a>
                        </script>
                        @if(_can('admin.basic.examupdate'))
                            <a class="layui-btn layui-btn-xs" onclick="admin.openLayerForm('{{ route("admin.basic.examupdate",['id' => $vo['id']]) }}', '编辑', 'POST', '600px', '550px')">编辑</a>
                        @endif
                        @if(_can('admin.basic.examdestroy'))
                            <a class="layui-btn layui-btn-xs layui-btn-danger" onclick="admin.tableDataDelete('{{ route("admin.basic.examdestroy", ['id' => $vo['id']]) }}', this,'确认删除吗')">删除</a>
                        @endif
                        @if(_can('admin.basic.memberindex'))
                            <a class="layui-btn layui-btn-xs" onclick="window.location.href='{{route('admin.basic.memberindex',['batch_id'=>$vo['id'],'basic_id'=>request('basic_id')])}}'">人员管理</a>
                        @endif
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
        @include("layout.page")
    </div>
@endsection

@section('script')
    <script src="{{asset('layui/modules/xm-select.js')}}"></script>
    <script src="{{asset('js/tree/select.js')}}"></script>
    <script>
        var idx=-1;
        layui.use(['form', 'table', 'layer','dropdown'], function () {
            var table = layui.table;
            var form = layui.form ,dropdown = layui.dropdown;
            table.init("table-hide");
            admin.paginate("{{ $data['total'] }}", "{{ $data['current_page'] }}", "{{ $data['per_page'] }}");
            table.on('tool(table-hide)', function (obj) {
                var that = this
                    , res = obj.data;
                //更多下拉菜单
                let buttons = [
                        @if(_can('admin.basic.examupdate')){title: '编辑批次', id: 'update',type:'openLayerForm',link:"{{ route_uri(session("guard").".basic.examupdate")}}",params:{id: res.id},set:{title:"编辑批次",method:"POST",width:"600px",height:"550px",repush:0,dome:"#update"}},@endif
                        @if(_can('admin.basic.membercreate')){title: '添加人员', id: 'membercreate',type:'link',link:"{{ route_uri(session("guard").".basic.membercreate")}}",params:{batch_id: res.id,basic_id:'{{request("basic_id")}}'}},@endif
                        @if(_can('admin.basic.memberindex')){title: '人员管理', id: 'setting',type:'link',link:"{{ route_uri(session("guard").".basic.memberindex")}}",params:{batch_id: res.id,basic_id:'{{request("basic_id")}}'}},@endif
                        @if(_can('admin.basic.examdestroy')){title: '删除批次', id: 'del',type:'tableDataDelete',link:"{{ route_uri(session("guard").".basic.examdestroy") }}",params:{id:res.id},set:{dome:this,title:"是否删除当前批次"}} @endif
                ]
                dropdown.render(tableButtonGroup(that,buttons))
            });

        });
    </script>
    <script src="{{asset('js/layCommon.js')}}"></script>
@endsection

